//
//  ST_ReceiveCommentsCellModel.swift
//  btvideo
//
//  Created by mac on 2020/5/28.
//  Copyright © 2020 JarvanZhang. All rights reserved.
//

import UIKit
import SwiftyJSON
import SwiftyAttributes



class ST_ReceiveCommentsCellModel : NSObject{

    var accid : String
    var own_member_accid : String
    var avatar : String
    var comment : String
    var commentMemberId : Int
    var content : String
    var createTime : Int
    var duration : Int
    var featureId : Int
    var featureName : String
    var groupId : Int
    var height : Int
    var nickname : String
    var ownMemberId : Int
    var targetCommentId : Int
    var targetMemberGender : Int
    var targetMemberId : Int
    var commentId = 0
    var targetMemberNickname : String
    var type : Int
    var videoUrl : String
    var width : Int
    var vip_expire:Int
    
    var bus_name:String
    
    var title_name:String
    
    var daily_content_id:Int
//    真人认证相关
    var face_audit_state:Int?

    var commentAttr = NSAttributedString()
    
    var subText = ""
    
    var commentHeight = 0.cgFloat
    
    var cellHeight = 0.cgFloat
    
    func setUpDataSet(){
        
        /*
        if Bool.random() {
            comment = "我是超级长的评论适合低粉红色地方和实地爽的飞ID是否合适地方化斯蒂芬his的返回的私房话ID是回复is的盒饭i暂时完成"
        }*/
        
        let commentAttr: [NSAttributedString.Key : Any] = [.font: UIFont.systemFont(ofSize: 14),.foregroundColor: UIColor.init(hex: 0x61666F) ?? .white,.paragraphStyle:NSParagraphStyle.create_line_spacing_paragraph_style(lineSpacing: 5)]
        
        let commentAttrStr = NSMutableAttributedString.init(string: comment)
        
        commentAttrStr.addAttributes(commentAttr, range: NSRange.init(location: 0, length: commentAttrStr.length))
        
        self.commentAttr = commentAttrStr
        
        /*
        1.评论了你的特质 XXX
        2.回复了你的评论
        3.回复了XXX的评论
        */
        
//        是回复
        if targetMemberId != 0{
//            3.回复了XXX的评论
            if targetMemberNickname.count > 0{
                self.subText = "回复了"+targetMemberNickname+"的评论"
            }
//          2.回复了你的评论
            else{
                self.subText = "回复了你的评论"
            }
        }
//      1.评论了你的特质 XXX
        else{
            
            self.subText = "评论了你的"+title_name+" " + bus_name
        }
        
        
        
        
        commentHeight = commentAttrStr.height(withConstrainedWidth: ScreenWidth-71-15)
        
        cellHeight = commentHeight + 15 + 73
    }
    
    
    /**
     * Instantiate the instance using the passed json values to set the properties values
     */
    init(fromJson json: JSON){
        
        
        commentId = json["comment_id"].intValue
        accid = json["accid"].stringValue
        own_member_accid = json["own_member_accid"].stringValue
        
        avatar = json["avatar"].stringValue
        comment = json["comment"].stringValue
        commentMemberId = json["comment_member_id"].intValue
        content = json["content"].stringValue
        createTime = json["create_time"].intValue
        duration = json["duration"].intValue
        featureId = json["feature_id"].intValue
        featureName = json["feature_name"].stringValue
        groupId = json["group_id"].intValue
        height = json["height"].intValue
        nickname = json["nickname"].stringValue
        ownMemberId = json["own_member_id"].intValue
        targetCommentId = json["target_comment_id"].intValue
        targetMemberGender = json["target_member_gender"].intValue
        targetMemberId = json["target_member_id"].intValue
        targetMemberNickname = json["target_member_nickname"].stringValue
        type = json["type"].intValue
        videoUrl = json["video_url"].stringValue
        width = json["width"].intValue
        
        face_audit_state = json["face_audit_state"].int
        
        vip_expire = json["vip_expire"].intValue
        
        
        bus_name = json["bus_name"].stringValue
        
        title_name = json["title_name"].stringValue
        
        daily_content_id = json["daily_content_id"].intValue
        
        super.init()
        
        setUpDataSet()
    }
    
}
